import React, { PureComponent } from 'react'
import { connect } from 'react-redux'

import {addNumber} from '../store/features/counter'

export class Profile extends PureComponent {
  addNumber(num){
    this.props.addNumber(num)
  }

  render() {
    const { counter } = this.props
    return (
      <div>
        <h1>Profile:{counter}</h1>
        <button onClick={e=>this.addNumber(5)}>+5</button>
        <button onClick={e=>this.addNumber(10)}>+10</button>
      </div>
    )
  }
}
const mapStateToProps = (state)=>({
  counter:state.counter.counter
})
const mapDispatchToProps = (dispatch)=>({
  addNumber(num){
    dispatch(addNumber(num))
  }

})
export default connect(mapStateToProps,mapDispatchToProps)(Profile) 